home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / EGAVGA.SWG / 0032_SETPAGE.PAS.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  2KB  |  49 lines

  1. {
  2.  Hi..  I am trying to do animation by flipping the two images between
  3.  the video pages, but I keep getting lines at the bottom of my screen,
  4.  and my screen color changes..  What's up here?
  5.  Did you synchronize to the {vertical|horizontal retrace beFore
  6.  flipping? I don't know how to do this, so any helpfull code from you will
  7.  be appreciated. I took this out of my ANIVGA-Unit:
  8.  
  9. At the very beginning of your Program, detect the address of the proper port
  10. (StatusReg is a global Word Variable):
  11. }
  12.  
  13.  Asm  {check whether we are running on a monochrome or color monitor}
  14.    MOV DX,3CCh  {ask Output-register:}
  15.    in AL,DX
  16.    TEST AL,1    {is it a color monitor?}
  17.    MOV DX,3D4h
  18.    JNZ @L1      {yes}
  19.    MOV DX,3B4h  {no }
  20.   @L1:          {DX=3B4h/3D4h = CrtAddress-register For monochrome/color}
  21. { MOV CrtAddress,DX  not needed For this purpose}
  22.    ADD DX,6     {DX=3BAh/3DAh = Status-register For monochrome/color}
  23.    MOV StatusReg,DX
  24.  end; {of Asm}
  25.  
  26. {
  27. Later on, when you want to switch pages:
  28.  
  29.    CLI {time critical routine: do not disturb!}
  30.     mov dx,StatusReg
  31.   @WaitnotVSyncLoop:
  32.     in   al,dx
  33.     and  al,8
  34.     jnz  @WaitnotVSyncLoop
  35.   @WaitVSyncLoop:
  36.     in   al,dx
  37.     and  al,8
  38.     jz   @WaitVSyncLoop
  39. {
  40.     HERE! SWITCH PAGES NOW!!! IMMEDIATELY! do not USE BIOS-inTS or OTHER
  41.     TIME-WASTERS!
  42. }
  43.    STI
  44. {
  45. Well, that's all there is... if you replace the 2 "and al,8" against "and al,1"
  46. and exchange jnz<->jz, you are syncronizing at the horizontal retrace. But this
  47. signal is extremely short (at least Compared With the vertical retr.).
  48. }
  49.